<!DOCTYPE html>
<html>
  <head>
    <title>MyDocs</title>
    
      <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.41" />
<title>镜像 :: MyDocs</title>
<link rel="shortcut icon" href="/images/favicon.png" type="image/x-icon" />
<link href="/css/font-awesome.min.css" rel="stylesheet">
<link href="/css/nucleus.css" rel="stylesheet">
<link href="/theme-flex/style.css" rel="stylesheet">

<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/jquery-2.x.min.js"></script>
<script type="text/javascript">
      var baseurl = "\/";
</script>
<meta name="description" content="">



    
  </head>
  <body data-url="/docker/03_%E9%95%9C%E5%83%8F/">
    
      <header>
  <div class="logo">
    
	
  
    <a class="baselink" href="/">MyDocs</a>
  

  </div>
  <div class="burger"><a href="javascript:void(0);" style="font-size:15px;">&#9776;</a></div>
    <nav class="shortcuts">
            <li class="" role="">
                <a href=""  rel="noopener">
                  
                </a>
            </li>
    </nav>
</header>
<article>
  <aside>
    <ul class="menu">
          <li data-nav-id="/" class="dd-item">
          <a href="/">
            <i class="fa fa-fw fa-home"></i>
          </a>
          </li>
    <li data-nav-id="/hugo/" class="dd-item
        ">
      <div>
      <a href="/hugo/">Hugo</a><i class="fa fa-circle-thin read-icon"></i>
      </div>
    </li>
    <li data-nav-id="/docker/" class="dd-item parent haschildren
        ">
      <div>
      <a href="/docker/">Dockers</a>
            <i class="fa fa-angle-down fa-lg category-icon"></i><i class="fa fa-circle-thin read-icon"></i>
      </div>
        <ul>
      <li data-nav-id="/docker/01_%E5%AE%89%E8%A3%85/" class="dd-item">
        <div>
          <a href="/docker/01_%E5%AE%89%E8%A3%85/">
            安装
          </a><i class="fa fa-circle-thin read-icon"></i>
        </div>
    </li>
      <li data-nav-id="/docker/02_%E6%A6%82%E5%BF%B5/" class="dd-item">
        <div>
          <a href="/docker/02_%E6%A6%82%E5%BF%B5/">
            概念
          </a><i class="fa fa-circle-thin read-icon"></i>
        </div>
    </li>
      <li data-nav-id="/docker/03_%E9%95%9C%E5%83%8F/" class="dd-item active">
        <div>
          <a href="/docker/03_%E9%95%9C%E5%83%8F/">
            镜像
          </a><i class="fa fa-circle-thin read-icon"></i>
        </div>
    </li>
        </ul>
    </li>




    </ul>
    <section>
    </section>
  </aside>
  <section class="page">
    
    <div class="nav-select">
      <center>Navigation : 
        <select onchange="javascript:location.href = this.value;">
          
    <option value="/hugo/" >
   Hugo</option>
    <option value="/docker/" >
   Dockers</option> 
      <option value="/docker/01_%E5%AE%89%E8%A3%85/" >- 安装</option>
      <option value="/docker/02_%E6%A6%82%E5%BF%B5/" >- 概念</option>
      <option value="/docker/03_%E9%95%9C%E5%83%8F/"  selected>- 镜像</option>
  



        </select>
      </center>
    </div>
      <div>
        <div class="searchbox">
          <input data-search-input id="search-by" type="text" placeholder="Search...">
        </div>
        <script type="text/javascript" src="/js/lunr.min.js"></script>
        <script type="text/javascript" src="/js/auto-complete.js"></script>
        <link href="/css/auto-complete.css" rel="stylesheet">
        <script type="text/javascript">
          
              var baseurl = "\/";
          
        </script>
        <script type="text/javascript" src="/js/search.js"></script>
      </div>
    

    <h1>镜像</h1>
    
    
    
    

<h3 id="文档">文档</h3>

<h3 id="获取镜像">获取镜像</h3>

<p>从Docker Registry获取镜像的命令是docker pull。<br />
其命令格式为： docker  pull [选项]   [Docker Registry地址]&lt;仓库名&gt;:&lt;标签&gt;</p>

<p>具体的选项可以通过 docker    pull    &ndash;help  命令看到。</p>

<p>DockerRegistry地址：地址的格式一般是 &lt;域名/IP&gt;[:端口号]。 默认地址是Docker Hub。<br />
仓库名：如之前所说，这里的仓库名是两段式名称，既     &lt;用户名&gt;/&lt;软件名&gt;。<br />
对于  Docker Hub，如果不给出用户名，则默认为    library ，也就是官方镜像。</p>
<div class="highlight"><pre style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh"><span style="color:#75715e"># sudo docker image pull [options] [仓库地址] &lt;仓库名称&gt;:&lt;标签&gt; 
</span><span style="color:#75715e"># 完整:
</span><span style="color:#75715e"># sudo docker image pull hub.docker.com library/ubuntu:16.04
</span><span style="color:#75715e"># 简写: 
</span><span style="color:#75715e"></span>sudo docker image pull ubuntu:16.04 </code></pre></div>
<h3 id="运行">运行</h3>

<p>有了镜像后，我们就可以以这个镜像为基础启动一个容器来运行。</p>
<div class="highlight"><pre style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh"><span style="color:#75715e">#sudo docker container run -it --rm &lt;仓库名称&gt;:&lt;tag&gt;  &lt;cmd&gt;
</span><span style="color:#75715e"></span>sudo docker container run -it --rm ubuntu:16.04 bash</code></pre></div>
<ul>
<li>-it： 这是两个参数，一个是-i：交互式操作，一个是-t 终端。</li>

<li><p>&ndash;rm ：这个参数是说容器退出后随之将其删除。<br />
默认情况下，为了排障需求，退出的容 器并不会立即删除，除非手动docker rm。</p></li>

<li><p>ubuntu:16.04 ：这是指用 ubuntu:16.04 镜像为基础来启动容器。</p></li>

<li><p>bash: 放在镜像名后的是命令</p></li>
</ul>


    
    
        <div class="chevrons">
    <div id="navigation">
<a class="nav nav-prev" href="/docker/02_%E6%A6%82%E5%BF%B5/" title="概念"> <i class="fa fa-chevron-left"></i><label>概念</label></a>
    <a class="nav nav-next" href="/docker/01_%E5%AE%89%E8%A3%85/" title="安装" style="margin-right: 0px;"><label>安装</label><i class="fa fa-chevron-right"></i></a></div>
  </div>

  </section>
</article>

<footer>

<div class="footline">
    

    

  
    <div class="date">
        <i class='fa fa-calendar'></i> Last update on 29/05/2018
    </div>
    

    <div class="github-link">
      <a href="https://github.com/vjeantet/hugo-theme-docdock/edit/master/exampleSite/content/docker/03_%e9%95%9c%e5%83%8f.md" target="blank"><i class="fa fa-code-fork"></i>
        Improve this page</a>
    </div>
  </div>


	<div>


  
    Create a content/_footer.md file to customize the footer content
  



	</div>
</footer>

<script src="/js/clipboard.min.js"></script>

<link href="/css/featherlight.min.css" rel="stylesheet">
<script src="/js/featherlight.min.js"></script>



<script src="/theme-flex/script.js"></script>

    

    
    

    
  </body>
</html>